/*
 * @file iso9660.c
 *
 *   ISO9660 block device I/O interface
 */
#if HAVE_CONFIG_H
#include "config.h"
#endif

#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>

#include <rtems.h>
#include <rtems/libio.h>
#include <rtems/bdbuf.h>
#include <rtems/seterr.h>

#include "iso9660.h"
#include "iso9660_io.h"


int
iso9660_regular_open(
    char              *device,
    struct stat       *host_volume,
    iso9660_fs_info_t  *fs
)
{
  fs->dd = open(device, O_RDONLY);

  if (fs->dd == -1)
    rtems_iso9660_error_and_return_minus_one(errno,
        "regular_open: failed to open source device for read-only operations.");

  fs->media_size = host_volume->st_size;
  fs->dev = host_volume->st_dev;

  fs->type = ISO9660_VOLUME_TYPE_REGULAR;

  return 0;
}
